#include "sprite.h"


Sprite::Sprite()
{

}

Sprite::Sprite(Image *sourceImage, RectangleWH area)
{
    this->sourceImage = sourceImage;
    this->area = area;
}

Sprite::Sprite(Image *sourceImage, Vector2 spriteLayout, Vector2 spriteSize, int spriteNumber)
{
   int x = ((spriteNumber - 1) % int(spriteLayout.GetX())) * spriteSize.GetX();
   int y = ((spriteNumber - 1)/ int(spriteLayout.GetX())) * int(spriteSize.GetY());
   int w = spriteSize.GetX();
   int h = spriteSize.GetY();
   area = RectangleWH(x, y, w, h);
   this->sourceImage = sourceImage;

//    RectangleWH area = RectangleWH(
//                                   (spriteNumber % int(spriteLayout.GetX())) * int(spriteSize.GetX()),
//                                   (spriteNumber / int(spriteLayout.GetX())) * int(spriteSize.GetY()),
//                                   int(spriteSize.GetX()), int(spriteSize.GetY())
//                                  );
}


Sprite::~Sprite()
{
    //dtor
}

void Sprite::Draw(Vector2 drawLocation)
{  //Not crashy
    sourceImage->Draw(drawLocation, area, false, false, 1, Color(1, 1, 1, 1));
    //sourceImage->Draw(drawLocation, Color(1, 1, 1, 1));
}

